package com.example.controller;

import com.example.dto.vehicle.Vehicle;
import com.example.server.VehicleServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@Api(tags = "新能源重卡")
@RequestMapping("/api/veh")
public class VehicleController {

    @Autowired
    private VehicleServer vehicleServer;

    @ApiOperation("增加车辆信息")
    @PostMapping
    public Map<String, Object> add(@RequestBody Vehicle vehicle) {
        Map<String, Object> result = new HashMap<>(4);
        if (vehicle == null) {
            result.put("code", 401);
            result.put("msg", "请输入信息");
            return result;
        }
        result = vehicleServer.creat(vehicle);
        return result;
    }
}
